********************************************************************************
*This file is for the EV treatment only.
*This file does the calculations for the following tables:
* Table 7
* Table 9.
*This file produces the following figures:
* Figure 3 (b)
* Figure 4 (b)
********************************************************************************


clear all
set more off
use EV_data_4_sessions

//calculate the expected monitoring level for drivers
sort session round group role
gen m_a_obs = m_a[_n-1] if role==2
gen m_b_obs = m_b[_n-1] if role==2
egen mon_temp_1 = rowmin(m_a_obs m_b_obs)
gen mon_temp_2 = (m_a_obs+m_b_obs)/2
gen mon_level = mon_temp_1 if is_observed == 1
replace mon_level = mon_temp_2 if is_observed == 0
drop mon_temp_1 mon_temp_2


preserve
collapse gender major age num_econ_classes gpa, by(stata_id)

su i.gender

su i.major

su age

su num_econ_classes

su gpa
restore


drop if role == 1 //drop the officers.

replace mon_level=round(mon_level, 0.005) //clean up any floating point arithmetic errors.


xtset stata_id


********************************************************************************
xtlogit chose_C c.mon_level##i.is_observed ib2.gender ib3.major age num_econ_classes gpa, pa vce(robust) corr(independent)
*Note that the variable mon_level is the V(m_a,m_b) function in the paper.
********************************************************************************


